﻿Imports ReglasNegocio
Imports System.Collections.Generic
Imports System.Data

Partial Public Class Reporte_Consolidado_Gastos_Excel
    Inherits System.Web.UI.Page

    Protected strFechaActual As String
    Protected strHoraActual As String
    Protected ParamLocal, ParamFecha1, ParamFecha2 As String
    Protected ParamNomLocal As String
    Protected dsConsulta1, dsConsulta2 As New DataSet

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Expires = 0
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1")
        Response.ContentType = "application/xls"
        Response.AppendHeader("Content-disposition", "attachment; filename=Reporte_Gastos_Consolidado.xls")
        SRT_RecuperacionFechas()
        CargaConsolidado(PreviousPage.CodLocalExcel, PreviousPage.CodItemExcel, PreviousPage.Fecha1Excel, PreviousPage.Fecha2Excel)
        CargaDetalleConsolidado(PreviousPage.CodLocalExcel, PreviousPage.CodItemExcel, PreviousPage.Fecha1Excel, PreviousPage.Fecha2Excel)
    End Sub

    Private Sub SRT_RecuperacionFechas()
        strFechaActual = Format(DateTime.Now.Date, "dd/MM/yyyy")
        Dim minuto As String
        If DateTime.Now.Minute < 10 Then
            minuto = "0" & DateTime.Now.Minute
        Else
            minuto = DateTime.Now.Minute
        End If
        strHoraActual = DateTime.Now.Hour & ":" & minuto
    End Sub


    Private Sub CargaConsolidado(ByVal pstrLocal As String, ByVal pstrInsumo As String, ByVal pstrFecha1 As String, ByVal pstrFecha2 As String)
        ParamLocal = pstrLocal
        ParamFecha1 = pstrFecha1
        ParamFecha2 = pstrFecha2

        Dim Catalogo As CatalogoConsolidado = New CatalogoConsolidado()
        dsConsulta1 = Catalogo.BandejaGastoConsolidado(pstrLocal, pstrInsumo, pstrFecha1, pstrFecha2)
        ParamNomLocal = PreviousPage.NomLocalExcel
    End Sub

    Private Sub CargaDetalleConsolidado(ByVal pstrLocal As String, ByVal pstrInsumo As String, ByVal pstrFecha1 As String, ByVal pstrFecha2 As String)
        Dim Catalogo As CatalogoConsolidado = New CatalogoConsolidado()
        dsConsulta2 = Catalogo.BandejaGastoConsolidadoTotal(pstrLocal, pstrInsumo, pstrFecha1, pstrFecha2)
    End Sub
End Class